--- id: TASK-032 title: Memoize editor visual model — fix scroll/open lag status: "\U0001F3C1 Done" assignee: [] created_date: '2026-06-30 20:44' updated_date: '2026-06-30 20:44' labels: - bug - performance dependencies: [] priority: high ordinal: 31000 --- ## Description buildVisual() rescanned+rewrapped+restyled the whole document on every View, cursor move, and scroll tick (no caching). Per single scroll row: 20ms/62MB at 500 lines, 133ms/345MB at 2000 lines w/ spell. Caused open-doc lag and scroll stutter. Fix: memoize the scan+wrap model (e.visual []vrow), invalidate only on scan/wrap input changes (Lines/Width/theme/spell/codeFile). Scroll/render now O(visible) ~0.4ms, independent of doc size. ## Acceptance Criteria - [ ] #1 Scroll + render reuse cached visual model (buildCount<=1 across scroll loop) - [ ] #2 Edits/theme/spell/width changes invalidate cache (no stale render) - [ ] #3 All tests pass